package org.poem.service;

import org.poem.api.DemoService;
import org.poem.dao.DemoDao;
import org.poem.entity.Demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DemoServiceImpl implements DemoService {

    @Autowired
    public DemoDao demoDao;


    @Override
    public void save(String name) {
        Demo demo = new Demo();
        demo.setName(name);
        this.demoDao.save(demo);
    }

    @Override
    public void delete(String id) {
        this.demoDao.delete(id);
    }

    @Override
    public void update(String id, String name) {
        Demo demo = this.demoDao.findOne(id);
        demo.setName(name);
        this.demoDao.save(demo);
    }

    @Override
    public List<?> query() {
        return this.demoDao.findAll();
    }
}
